
	class Lock {
		
		int num1,num2,num3;
		int status;
		int attemptno;
		
		public Lock(int entry1, int entry2, int entry3){
			num1 = entry1;
			num2 = entry2;
			num3 = entry3;
			status = 2;
			attemptno = 0;
		}
		
		public String getStatus(){
			if(this.status == 1){
				return ("Open");
			}
			else if (this.status == 2){
				return ("Closed");
			}
			else{
				return ("Jammed");
			}
		}
		
		public boolean checkJam(){
			return (status == 3);
		}
		
		public void closeLock(){
			if(status == 1){
				status = 2;
			}
		}
		
		public void openLock(){
			status = 1;
			attemptno = 0;
		}
		
		public void attemptOpen(int entry1,int entry2, int entry3){
			if(entry1 == num1 && entry2==num2 && entry3==num3 && status ==2){
				openLock();
			}
			else if((entry1 != num1 || entry2 != num2 || entry3 != num3) && status == 2){
				updateAttemptno();
			}
		}
		
		public void updateAttemptno(){
			attemptno ++;
			if(attemptno >= 3){
				status = 3;
			}
		}
		

}
